<template>
  <div @click="toggleLanguage">
    <svg-icon
      :icon="isEn ? 'icon-zhongwen_o' : 'icon-yingwen_o'"
      :size="iconSize"
      class="text-[#8c2c30]"/>
  </div>
</template>

<script setup>
import { computed, defineProps } from 'vue'
import { useLanguageStore } from '@/stores/language'

defineProps({
  iconSize: {
    type: String,
    default: '2em'
  }
})

// ---------------------语言设置-------------------
const languageStore = useLanguageStore()
const isEn = computed(() => languageStore.currentLanguage === 'en')

const toggleLanguage = () => {
  const newLang = languageStore.currentLanguage === 'zh' ? 'en' : 'zh'
  languageStore.setLanguage(newLang)
}
</script>

<style scoped lang="scss">
</style>
